package FunctionDemo.demo1;

import java.util.Arrays;
import java.util.Comparator;

public class test {
    public static void main(String[] args){
        // 创建一个数组
        Integer[] arr = {1,4,321,42111,51,10,7};
        // 匿名内部类
        // Arrays.sort(arr,new Comparator<Integer>(){
        //     @Override
        //     public int compare(Integer o1, Integer o2){
        //         return o1 - o2;
        //     }
        // });
        Arrays.sort(arr, test::sub);
        System.out.println(Arrays.toString(arr));
    }
    public static int sub(int a,int b){
        return a - b;
    }
}
